<?php if(!defined('HDPHP_PATH'))exit;C('SHOW_NOTICE',FALSE);?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>分类管理</title>
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/juanpi/Static/Admin/hdjs/hdjs.css"/>
    <script src="http://127.0.0.1/juanpi/Static/Admin/js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://127.0.0.1/juanpi/Static/Admin/hdjs/hdjs.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="http://127.0.0.1/juanpi/Static/Admin/bootstrap/css/bootstrap.min.css"/>
    <script type="text/javascript">
		$(function(){
			$('.open').toggle(function(){
				var cid = $(this).attr('cid');
				//改变class
    			$(this).removeClass('glyphicon-plus').addClass('glyphicon-minus');
				$('tr[pid=' + cid + ']').fadeIn(600);
			}, function(){
				var cid = $(this).attr('cid');
				$(this).removeClass('glyphicon-minus').addClass('glyphicon-plus');
				$('tr[pid=' + cid + ']').fadeOut(600);
			});
		});
	</script>
	<style type="text/css">
		a:hover{
			text-decoration: none;
		}
	</style>
</head>
<body>
<div class="wrap">
    <table class="hd-table hd-table-list">
        <thead>
        <tr pid=0>
            <td width="30"></td>
            <td>分类id</td>
            <td>分类名称</td>
            <td>分类排序</td>
            <td width="250">操作</td>
        </tr>
        </thead>
        <tbody>
        	<?php foreach ($data as $k=>$v){?>
        	<tr pid='<?php echo $v['pid'];?>'     <?php if($v["pid"] != 0){ ?>style='display:none'<?php } ?>>
	            <td width="30" cid='<?php echo $v['cid'];?>'>
	            	<a href="javascript:;" class="glyphicon glyphicon-plus open" cid='<?php echo $v['cid'];?>'></a>
	            </td>
	            <td><?php echo $v['cid'];?></td>
	            <td><?php echo $v['_name'];?></td>
	            <td><?php echo $v['csort'];?></td>
	            <td width="250">
	            	<a href="<?php echo U('addSon',array('cid'=>$v['cid']));?>" class="hd-btn hd-btn-success hd-btn-sm">添加子分类</a>
	            	    <?php if($v['pid'] == 0){ ?>
	            		<a href="<?php echo U('edit',array('cid'=>$v['cid']));?>" class="hd-btn hd-btn-primary hd-btn-sm">编辑</a>
	            	<?php }else{ ?>
	            		<a href="<?php echo U('editSon',array('cid'=>$v['cid']));?>" class="hd-btn hd-btn-primary hd-btn-sm">编辑</a>
	            	<?php } ?>
	            	<a href="javascript:del_modal(<?php echo $v['cid'];?>);" class="hd-btn hd-btn-danger hd-btn-sm">删除</a>
	            </td>
           	</tr>
           	<?php }?>
        </tbody>
    </table>
    <div class="page_hdjob">
        
    </div>
</div>

</body>
<script type="text/javascript">
	function del_modal(cid){
		hd_modal({
            width: 400,//宽度
            height: 120,//高度
            title: '确认删除吗？',//标题
            content: '',//提示信息
            button: true,//显示按钮
            button_success: "确定",//确定按钮文字
            button_cancel: "取消",//关闭按钮文字
            timeout: 0,//自动关闭时间 0：不自动关闭
            shade: true,//背景遮罩
            shadeOpacity: 0.3,//背景透明度
            success: function () {//点击确定后的事件
				location.href='<?php echo U("del");?>' + '&cid=' + cid;
            },
            cancel: function () {//点击关闭后的事件

            }
        });
	}	
</script>
</html>


